import http from '@/utils/http.js';

//查询海报
export function getconfig(data = {}) {
  return http.get('/stock/getconfig', {
    data,
    showLoading: false,
    // requestTaskKey:'getconfig',
  });
}

//查询Banner
export function getBanner(data = {}) {
  return http.get('/index/banner', {
    data,
    showLoading: false,
    requestTaskKey: 'getBanner',
  });
}

//查询海报
export function getNewStock(data = {}) {
  return http.get('/Indexnew/sgandps', {
    data,
    showLoading: false,
    requestTaskKey: 'sgandps',
  });
}
//查询是否中签
export function getZqTip(data = {}) {
  return http.get('/stock/ballot', {
    data,
    showLoading: false,
    requestTaskKey: 'getZq',
  });
}
//查询新闻
export function getNews(data = {}) {
  return http.get('/Indexnew/getGuoneinews', {
    data,
    showLoading: false,
    requestTaskKey: 'getNews',
  });
}

//新闻详情
export function getNewsDetail(data = {}) {
  return http.get('/Indexnew/getNewsssDetail', {
    data,
    showLoading: false,
    requestTaskKey: 'getNewsssDetail',
  });
}

//新闻详情
export function getNewssDetail(data = {}) {
  return http.get('/Index/getnewscatalogs_new_detail', {
    data,
    showLoading: false,
    requestTaskKey: 'getNewssDetail',
  });
}

//热门指数
export function hotIndex(data = {}) {
  return http.get('/Indexnew/sandahangqing_new', {
    data,
    showLoading: false,
    requestTaskKey: 'sandahangqing_new',
  });
}

export function searchStock(data = {}) {
  return http.get('/user/searchstrategy', {
    data,
    showLoading: false,
    requestTaskKey: 'searchStock',
  });
}

//自选列表
export function getZixuan(data = {}) {
  return http.get('/elect/getZixuanNew', {
    data,
    showLoading: false,
    requestTaskKey: 'getZixuan',
  });
}

//沪深
export function getTabDetail(data = {}) {
  return http.get('/Indexnew/getShenhuDetail', {
    data,
    showLoading: false,
    requestTaskKey: 'getTabDetail',
  });
}

//创业
export function getCyDetail(data = {}) {
  return http.get('/Indexnew/getCyDetail', {
    data,
    showLoading: false,
    requestTaskKey: 'getCyDetail',
  });
}

//科创
export function getKcDetail(data = {}) {
  return http.get('/Indexnew/getKcDetail', {
    data,
    showLoading: false,
    requestTaskKey: 'getKcDetail',
  });
}

//北证
export function getBjDetail(data = {}) {
  return http.get('/Indexnew/getBjDetail', {
    data,
    showLoading: false,
    requestTaskKey: 'getBjDetail',
  });
}

//北证
export function zdfenbu(data = {}) {
  return http.get('/Indexnew/zdfenbu', {
    data,
    showLoading: false,
    requestTaskKey: 'zdfenbu',
  });
}

//是否自选
export function stockDetail(data = {}) {
  return http.get('/Indexnew/getHqinfo_1', {
    data,
    showLoading: false,
    requestTaskKey: 'stockDetail',
  });
}

//加入自选
export function addzx(data = {}) {
  return http.post('/ask/addzx', {
    data,
    showLoading: false,
    requestTaskKey: 'addzx',
  });
}

//删除自选
export function delzx(data = {}) {
  return http.post('/ask/delzx', {
    data,
    showLoading: false,
    requestTaskKey: 'delzx',
  });
}

//买入操作
export function buyStock(data = {}) {
  return http.post('/deal/addStrategy', {
    data,
    showLoading: false,
    requestTaskKey: 'buyStock',
  });
}
//融买入操作
export function buyStockRq(data = {}) {
  return http.post('/deal/addStrategy_rq', {
    data,
    showLoading: false,
    requestTaskKey: 'buyStockRq',
  });
}

// 配资买入操作
export function buyStockPz(data = {}) {
  return http.post('/deal/addStrategy_pz', {
    data,
    showLoading: false,
    requestTaskKey: 'buyStockPz',
  });
}

//卖出操作
export function sellStock(data = {}) {
  return http.post('/deal/sell', {
    data,
    showLoading: false,
    requestTaskKey: 'sellStock',
  });
}
//配资卖出操作
export function sellAllStockPz(data = {}) {
  return http.post('/deal/sellAllStockPz', {
    data,
    showLoading: false,
    requestTaskKey: 'sellAllStockPz',
  });
}
//融券卖出操作sellAllStockRq
export function sellAllStockRq(data = {}) {
  return http.post('/deal/sellAllStockRq', {
    data,
    showLoading: false,
    requestTaskKey: 'sellAllStockRq',
  });
}
//增发卖出操作sellAllStockRq
export function sellAllStockDz(data = {}) {
  return http.post('/dzjy/closeOut_dz', {
    data,
    showLoading: false,
    requestTaskKey: 'sellAllStockDz',
  });
}
//卖出操作
export function sellStockRq(data = {}) {
  return http.post('/deal/sellRq', {
    data,
    showLoading: false,
    requestTaskKey: 'sellStockRq',
  });
}
//银证转入页面配置参数
export function bankConfig(data = {}) {
  return http.get('/index/getchargeconfignew', {
    data,
    showLoading: false,
    requestTaskKey: 'bankConfig',
  });
}

//新股申购列表
export function newStockList(data = {}) {
  return http.get('/subscribe/lst', {
    data,
    showLoading: false,
    requestTaskKey: 'newStockList',
  });
}

//新股申购详情
export function newStockDetail(data = {}) {
  return http.get('/subscribe/lstDetail', {
    data,
    showLoading: false,
    requestTaskKey: 'newStockDetail',
  });
}

//新股申购
export function newStockAdd(data = {}) {
  return http.post('/subscribe/add', {
    data,
    showLoading: false,
    requestTaskKey: 'newStockAdd',
  });
}

//大宗列表
export function tradeList(data = {}) {
  return http.get('/dzjy/lst', {
    data,
    showLoading: false,
    requestTaskKey: 'tradeList',
  });
}

//调研列表
export function tradeDyList(data = {}) {
  return http.get('/dzjy/lstDy', {
    data,
    showLoading: false,
    requestTaskKey: 'tradeDyList',
  });
}
//大宗购买
export function tradeAdd(data = {}) {
  return http.post('/dzjy/addStrategy_zfa', {
    data,
    showLoading: false,
    requestTaskKey: 'tradeAdd',
  });
}
//调研购买
export function tradeDyAdd(data = {}) {
  return http.post('/dzjy/addStrategy_dy', {
    data,
    showLoading: false,
    requestTaskKey: 'tradeDyAdd',
  });
}
//调研购买
export function tradeSellDy(data = {}) {
  return http.post('/dzjy/closeOut_dy', {
    data,
    showLoading: false,
    requestTaskKey: 'tradeSellDy',
  });
}
//调研当前持仓
export function getNowWarehouseDy(data = {}) {
  return http.get('/dzjy/getNowWarehouseDy', {
    data,
    showLoading: false,
    requestTaskKey: 'getNowWarehouseDy',
  });
}

//调研历史持仓
export function getNowWarehouseHistoryDy(data = {}) {
  return http.get('/dzjy/getNowWarehouse_lishiDy', {
    data,
    showLoading: false,
    requestTaskKey: 'getNowWarehouseHistoryDy',
  });
}
//大宗购买
export function tradeSell(data = {}) {
  return http.post('/dzjy/closeOut_dz', {
    data,
    showLoading: false,
    requestTaskKey: 'tradeSell',
  });
}

//大宗交易当前持仓
export function getNowWarehouse(data = {}) {
  return http.get('/dzjy/getNowWarehouse', {
    data,
    showLoading: false,
    requestTaskKey: 'getNowWarehouse',
  });
}

//大宗交易历史持仓
export function getNowWarehouseHistory(data = {}) {
  return http.get('/dzjy/getNowWarehouse_lishi', {
    data,
    showLoading: false,
    requestTaskKey: 'getNowWarehouseHistory',
  });
}

//线下配售列表
export function offlineList(data = {}) {
  return http.get('/subscribe/xxlst', {
    data,
    showLoading: false,
    requestTaskKey: 'offlineList',
  });
}
//即将上市列表
export function soonList(data = {}) {
  return http.get('/subscribe/lst', {
    data,
    showLoading: false,
    requestTaskKey: 'soonList',
  });
}
//线下配售
export function offlineAdd(data = {}) {
  return http.post('/subscribe/xxadd?type=0', {
    data,
    showLoading: false,
    requestTaskKey: 'offlineAdd',
  });
}

//配售记录
export function offlineHistory(data = {}) {
  return http.get('/subscribe/getsgnewgu', {
    data,
    showLoading: false,
    requestTaskKey: 'offlineHistory',
  });
}

// 全部已读
export function allRead() {
  return http.get('/news/allread', {
    showLoading: false,
    requestTaskKey: 'allRead',
  });
}
// 模拟 getMsgs 函数
const mockGetMsgs = (params) => {
  return new Promise((resolve) => {
    const mockData = {
      data: {
        list: {
          data: Array.from({ length: 10 }, (_, i) => ({
            id: i + 1 * 10,
            title: `消息标题 ${i + 1 * 10}`,
            createtime: `2024-01-${(i + 1).toString().padStart(2, '0')}`,
            is_read: Math.random() > 0.5 ? 1 : 0,
          })),
        },
      },
    };
    setTimeout(() => {
      resolve(mockData);
    }, 500);
  });
};
export function getMsgs(data = {}) {
  return http.post('/news/index', {
    data,
    showLoading: false,
    requestTaskKey: 'getMsgs',
  });
  // return mockGetMsgs();
}

export function getNewsItemDetail(data = {}) {
  return http.get('/news/detail', {
    data,
    showLoading: true,
    requestTaskKey: 'getNewsDetail',
  });
}
